package me.jessyan.armscomponent.app.di.module;

import android.view.View;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.utils.ArmsUtils;

import java.util.ArrayList;
import java.util.List;

import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import me.jessyan.armscomponent.app.mvp.contract.mine.MineRewardContract;
import me.jessyan.armscomponent.app.mvp.model.mine.MineRewardModel;
import me.jessyan.armscomponent.app.mvp.model.entity.RewardItem;
import me.jessyan.armscomponent.app.mvp.ui.adapter.MineRewardAdapter;


/**
 * <p>
 * Author: Taozebi
 * Date: 08/16/2021 21:35
 * Description: describe of this class
 */
@Module
public abstract class MineRewardModule {

    @Binds
    abstract MineRewardContract.Model bindMineRewardModel(MineRewardModel model);

    @ActivityScope
    @Provides
    static RecyclerView.LayoutManager provideLayoutManager(MineRewardContract.View view) {
        return new LinearLayoutManager(view.getActivity());
    }

    @ActivityScope
    @Provides
    static List<RewardItem> provideList() {
        return new ArrayList<>();
    }

    @ActivityScope
    @Provides
    static RecyclerView.Adapter provideMineRewardAdapter(MineRewardContract.View mineRewardView,List<RewardItem> list) {
        MineRewardAdapter adapter = new MineRewardAdapter(list);
        adapter.setOnItemClickListener(new DefaultAdapter.OnRecyclerViewItemClickListener<RewardItem>() {
            @Override
            public void onItemClick(@NonNull View view, int viewType, @NonNull RewardItem data, int position) {
                ArmsUtils.snackbarText("position:"+position);
            }
        });
        return adapter;
    }
}